import {
    request2Promise,
    apiGET
} from "@/common/services/apiRequest.js"
import {
    _mockLessonList,
    _mockLessonUnitList
} from "./mock.js"
/**
 * 获取课程列表
 * @param {Object} pageNo
 * @param {Object} pageSize
 */
function getLessonList(pageNo, pageSize) {
    // if (!pageNo || !pageSize) {
    //     throw new Error("getLessonList 参数错误");
    // }
    return request2Promise(apiGET, {
        url: `/v1/category/?pageNo=${pageNo}&pageSize=${pageSize}`
    })
}

/**
 * 获取课程文章章节列表
 * @param {Object} pageNo
 * @param {Object} pageSize
 * @param {Object} lessonId 课程id
 */
function getLessonUnitList(pageNo, pageSize, lessonId) {
    console.log("getLessonUnitList", pageNo, pageSize, lessonId);
    if (!pageNo || !pageSize || !lessonId) {
        throw new Error("getLessonUnitList 参数错误");
    }
    return request2Promise(apiGET, {
        url: `/v1/article/?pageNo=${pageNo}&pageSize=${pageSize}&categoryId=${lessonId}`
        // url: `/v1/article/?pageNo=${pageNo}&pageSize=${pageSize}&categoryId=32`
    })
}

module.exports = {
    getLessonList,
    getLessonUnitList,

}